<?php
namespace ZfcUser\Model;

use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql;
use Zend\Db\Sql\Where;
use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;
use Zend\Db\Sql\Predicate;
use Zend\Db\Sql\Expression;
use Zend\Paginator\Paginator;

class TordersTable
{
    protected $tableGateway;
	protected $select;
    public function __construct(TableGateway $tableGateway)
    {
        $this->tableGateway = $tableGateway;
		$this->select = new Select();
    }
	
	public function addOrder($order,$uesrId)
    {
		$data = array(
			'user_id'				=>	$uesrId,
			'ship_address'			=> 	$order['address'],			
			'ship_city'  			=> 	$order['city'],
			'ship_state'  			=> 	$order['state'],
			'order_amount'			=>	$order['orderAmount'],
			'create_date'			=>	date('Y-m-d H:i:s'), 	
			'email_id'				=> 	$order['emailId'],  	
		);
		
		$this->tableGateway->insert($data);
		
		$select = $this->tableGateway->getSql()->select()
				->where('email_id="'.$order['emailId'].'"');
		$resultSet = $this->tableGateway->selectWith($select);
		$row = $resultSet->current();
		return $row;
    }
	
}